home *** CD-ROM | disk | FTP | other *** search
/ Champak 52 / Volume 52 - JOGO DISK .iso / Games / shopdrop.swf / scripts / __Packages / smashing / Menu.as < prev    next >
Text File  |  2007-09-27  |  4KB  |  148 lines

  1. class smashing.Menu extends MovieClip
  2. {
  3.    static var bInited = smashing.Menu.init();
  4.    var bEnabled = true;
  5.    function Menu()
  6.    {
  7.       super();
  8.       smashing.Menu.target = this;
  9.    }
  10.    static function init()
  11.    {
  12.       smashing.Menu.aWatched = [];
  13.       return true;
  14.    }
  15.    function onShow()
  16.    {
  17.    }
  18.    function onResume()
  19.    {
  20.    }
  21.    function show(sFrame)
  22.    {
  23.       this.onShow();
  24.       this.gotoAndPlay(sFrame);
  25.    }
  26.    function resume()
  27.    {
  28.       this.onResume();
  29.       this.gotoAndStop("blank");
  30.    }
  31.    function restoreVals()
  32.    {
  33.       var _loc3_ = smashing.Menu.aWatched;
  34.       var _loc4_ = _loc3_.length;
  35.       var _loc1_ = undefined;
  36.       var _loc2_ = 0;
  37.       while(_loc2_ < _loc4_)
  38.       {
  39.          _loc1_ = _loc3_[_loc2_];
  40.          if(_loc1_.fMethod != undefined)
  41.          {
  42.             _loc1_.fMethod(_loc1_.sProp,"foo",smashing.Menu.target[_loc1_.sProp + "cache"]);
  43.          }
  44.          _loc2_ = _loc2_ + 1;
  45.       }
  46.    }
  47.    function playAgain()
  48.    {
  49.    }
  50.    static function watchProp(o, sProp, sType)
  51.    {
  52.       var _loc1_ = new smashing.MenuEntry();
  53.       _loc1_.sProp = sProp;
  54.       switch(sType)
  55.       {
  56.          case "text":
  57.             o.watch(sProp,smashing.Menu.watchText);
  58.             _loc1_.fMethod = smashing.Menu.watchText;
  59.             break;
  60.          case "frameMeter":
  61.             o.watch(sProp,smashing.Menu.watchFrameMeter);
  62.             _loc1_.fMethod = smashing.Menu.watchFrameMeter;
  63.             break;
  64.          case "frameAnimMeter":
  65.             o.watch(sProp,smashing.Menu.watchFrameAnimMeter);
  66.             _loc1_.fMethod = smashing.Menu.restoreFrameAnimMeter;
  67.             break;
  68.          case "pegboard":
  69.             o.watch(sProp,smashing.Menu.watchPegboard);
  70.             _loc1_.fMethod = smashing.Menu.watchPegboard;
  71.             break;
  72.          case "signboard":
  73.             o.watch(sProp,smashing.Menu.watchSignboard);
  74.             break;
  75.          case "singleDigit":
  76.             o.watch(sProp,smashing.Menu.watchSingleDigit);
  77.             _loc1_.fMethod = smashing.Menu.watchSingleDigit;
  78.       }
  79.       smashing.Menu.aWatched.push(_loc1_);
  80.    }
  81.    static function watchText(prop, oldVal, newVal)
  82.    {
  83.       smashing.Menu.target[prop.toString()] = newVal;
  84.       smashing.Menu.target[prop.toString() + "cache"] = newVal;
  85.       return newVal;
  86.    }
  87.    static function watchFrameMeter(prop, oldVal, newVal)
  88.    {
  89.       var _loc2_ = smashing.Menu.target[prop.toString()];
  90.       var _loc1_ = Math.ceil(newVal * _loc2_._totalframes);
  91.       if(_loc1_ == 0)
  92.       {
  93.          _loc1_ = 1;
  94.       }
  95.       _loc2_.gotoAndStop(_loc1_);
  96.       smashing.Menu.target[prop.toString() + "cache"] = newVal;
  97.       return newVal;
  98.    }
  99.    static function watchFrameAnimMeter(prop, oldVal, newVal)
  100.    {
  101.       var _loc1_ = smashing.Menu.target[prop.toString()];
  102.       var _loc2_ = newVal;
  103.       _loc1_.gotoAndPlay("life" + _loc2_);
  104.       smashing.Menu.target[prop.toString() + "cache"] = newVal;
  105.       return newVal;
  106.    }
  107.    static function restoreFrameAnimMeter(prop, oldVal, newVal)
  108.    {
  109.       var _loc1_ = smashing.Menu.target[prop.toString()];
  110.       var _loc2_ = newVal;
  111.       _loc1_.gotoAndStop("rest" + _loc2_);
  112.       smashing.Menu.target[prop.toString() + "cache"] = newVal;
  113.       return newVal;
  114.    }
  115.    static function watchPegboard(prop, oldVal, newVal)
  116.    {
  117.       var _loc3_ = smashing.Menu.target[prop.toString()];
  118.       _loc3_.pegs = newVal;
  119.       smashing.Menu.target[prop.toString() + "cache"] = newVal;
  120.       return newVal;
  121.    }
  122.    static function watchSignboard(prop, oldVal, newVal)
  123.    {
  124.       var _loc4_ = 1;
  125.       var _loc2_ = smashing.Menu.target[prop.toString()];
  126.       _loc2_.gotoAndStop(newVal);
  127.       _loc2_.startTime = getTimer();
  128.       _loc2_.limit = _loc4_;
  129.       _loc2_.onEnterFrame = function()
  130.       {
  131.          var _loc2_ = (getTimer() - this.startTime) / 1000;
  132.          if(_loc2_ >= this.limit)
  133.          {
  134.             this._visible = false;
  135.             delete this.onEnterFrame;
  136.          }
  137.       };
  138.       return newVal;
  139.    }
  140.    static function watchSingleDigit(prop, oldVal, newVal)
  141.    {
  142.       var _loc1_ = smashing.Menu.target[prop.toString()];
  143.       _loc1_.gotoAndStop(newVal + 1);
  144.       smashing.Menu.target[prop.toString() + "cache"] = newVal + 1;
  145.       return newVal;
  146.    }
  147. }
  148.